<%@ page language="java" import="java.util.*,com.beans.*,com.dao.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
	<style>
		#div_top{
			margin:0 auto;
			width:866px;
			padding-top:7px;
			text-align: center;
		}
		#img_title{
			width:790px;
			height:142px;
			margin-bottom: 5px;
		}
		#div_menu a{
			margin:0;
			padding:0;
			display:inline-block;
			list-style-type: none;
			background: url(${pageContext.request.contextPath}/images/beijingyanse.jpg);
			width:192px;
			height:35px;
			line-height: 35px;
			text-align: center;
			text-decoration: none;
			color:white;
			font-weight: bold;
		}
	
		#div_menu a:hover{
			color:red;
		}

		div img{
			vertical-align:middle;
			border:0px;
		}
		
		a{
			color:black;
			text-decoration: none;
		}
		a:hover{
			color:red;
		}
		
		.a_homepage{
			font-size:12px;
		}
	</style>
	
	<script src="${pageContext.request.contextPath }/js/jquery-1.4.4.js"></script>
	<script>

		function SetHome(obj, vrl) {
			try {
				obj.style.behavior = 'url(#default#homepage)';
				obj.setHomePage(vrl);
			} catch (e) {
				if (window.netscape) {
					try {
						netscape.security.PrivilegeManager
								.enablePrivilege("UniversalXPConnect");
					} catch (e) {
						alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
					}
					var prefs = Components.classes['@mozilla.org/preferences-service;1']
							.getService(Components.interfaces.nsIPrefBranch);
					prefs.setCharPref('browser.startup.homepage', vrl);
				} else {
					alert("您的浏览器不支持，请按照下面步骤操作：1.打开浏览器设置。2.点击设置网页。3.输入：" + vrl
							+ "点击确定。");
				}
			}
		}
	</script>
	<script>
		$(function(){
			$("#bigCateId").change(function(){
				var parentId=this.value;
				$.ajax({
					url:"AjaxCategoryServlet",
					type:"post",
					data:{cateId:parentId},
					dataType:"json",
					success:function(cateList){
						$("#smallCateId").empty();
						$("#smallCateId").append("<option VALUE='0'>小分类 </option>");
						$.each(cateList,function(index,cateInfo){
							var smallCateId = '${smallCateId}';
							if(smallCateId!="0"){
								var str="<option value='"+cateInfo.id+"' selected>"+cateInfo.cateName+"</option>" ;
							}else{
								var str="<option value='"+cateInfo.id+"'>"+cateInfo.cateName+"</option>" ;
							}
							$("#smallCateId").append(str);
						});
					}
					
				});
			});
			$("#bigCateId").change();
		});
	</script>
		
	<%
       	//查询所有大分类
       	List<CateInfo> cateList=CateDao.getCategotyList(0);
       	request.setAttribute("cateList", cateList);
	%>
	
    <div id="div_top">
    					
				         
     	<form action="${pageContext.request.contextPath }/GoodsServlet?flag=search" method="post"  >
			 <div>
			  		<a href="${pageContext.request.contextPath }/user/userLogin.jsp"  target="_parent">
			        	 <img src="${pageContext.request.contextPath }/images/denglu.bmp" />
			         </a>
			         <a href="${pageContext.request.contextPath }/user/userRegister.jsp"  target="_parent">
					 	<img src="${pageContext.request.contextPath }/images/zhuce.bmp" >
					 </a>
					 <a href="javascript:alert('请登录')">
				   	  	<img src="${pageContext.request.contextPath }/images/yonghuxinxi.bmp" >
				     </a>
				     <a class="a_homepage" href="javascript:SetHome(this,window.location)" >将Eshop商城设为主页    </a>
				     <img src="${pageContext.request.contextPath }/images/icon_login.gif" >
				    
			         <input type="text" id="goodsName" name="goodsName" placeholder="商品关键字"  onfocus="this.value=''" />
	
				     <select name="bigCateId" id="bigCateId">
			            <option value="0">大分类 </option>
			            <c:forEach var="c" items="${cateList}">
			            	<option value="${c.id}" <c:if test="${bigCateId==c.id }">selected</c:if>>${c.cateName }</option>
			            </c:forEach>
			         </select>
			
			         <select id="smallCateId" name="smallCateId">
			            <option VALUE="0">小分类 </option>
			         </select>
				     <input type="image" src="${pageContext.request.contextPath }/images/icon_search.gif" />
				     
			 </div>
			
			 <img id="img_title" src="${pageContext.request.contextPath }/images/title.jpg"  >
			 <div id="div_menu">
			 	<a href="${pageContext.request.contextPath }/index.jsp">商城首页</a> 
			 	<a href="${pageContext.request.contextPath }/shopping/shopCartList.jsp" >购物车管理</a> 
			 	<a href="${pageContext.request.contextPath }/ShopCartServlet?flag=zhifu">支付管理</a>   
			 	<a href="${pageContext.request.contextPath }/order/orderSearch.jsp">订单管理</a>
			 </div> 
		  </form>
    </div>

